package com.pivotal.cloud.crypto.encrypt;

import com.pivotal.cloud.crypto.codec.Hex;
import com.pivotal.cloud.crypto.codec.Utf8;

/**
 * @className: com.pivotal.cloud.security.crypto.encrypt.HexEncodingTextEncryptor
 * @projectName: 项目
 * @module: 项目-HexEncodingTextEncryptor类，主要位于模块
 * @content:
 * @author: Powered by Marklin
 * @datetime: 2025-06-25 23:05
 * @version:
 * @copyright: Copyright © 2018-2025 Systems Incorporated. All rights reserved.
 */
public final class HexEncodingTextEncryptor implements TextEncryptor {

	private final BytesEncryptor encryptor;

	HexEncodingTextEncryptor(BytesEncryptor encryptor) {
		this.encryptor = encryptor;
	}

	@Override
	public String encrypt(String text) {
		return new String(Hex.encode(this.encryptor.encrypt(Utf8.encode(text))));
	}

	@Override
	public String decrypt(String encryptedText) {
		return Utf8.decode(this.encryptor.decrypt(Hex.decode(encryptedText)));
	}

}
